<template>
	<!-- 瀑布流排版 -->
	<view class="" style="height: 100%;">
		<view class="waterfall" :style="{'background': backgroundColor}">
			<uv-waterfall ref="waterfall" v-model="goodsList" :add-time="50" column-count="2" left-gap="10"
				right-gap="10" column-gap="8" column-width="40" @changeList="changeList">
				<template v-slot:list1>
					<view>
						<view v-for="(item, index) in list1" :key="index" class="waterfall-item">
							<view @click="todetail(item.id)" class="waterfall-item__image">
								<image v-if="item.hasVideo" src="https://image.hzwltb69.com/app/imgs/chat/live.gif"
									class="lives" mode=""></image>
								<uv-image :src="item.img" mode="widthFix" width="350rpx">
									<template v-slot:loading>
										<image class="loadingLogo"
											src="https://image.hzwltb69.com/app/date/2023/lodingLogo.png"
											mode="widthFix"></image>
									</template>
								</uv-image>
							</view>
							<view class="p-title">
								{{item.name}}
							</view>
							<!-- <view class="p-pirce">
								<view class="">
									<text style="font-size: 22rpx;">￥</text>{{item.price}}
									<span
										style="font-size: 22rpx;color: #999999;margin-left: 20rpx;">{{item.paySales}}人付款</span>
								</view>
								<view class="cat">
									<img src="https://image.hzwltb69.com/app/date/2023/cat.png" alt="">
								</view>
							</view> -->
							<view class="p-pirce">
								<view class="">
									<text style="font-size: 22rpx;margin-right: 2rpx;">￥</text>{{item.price}}
								</view>
								<view class="cat">抢购</view>
							</view>
							<view class="line" v-if="item.paySales != 0"></view>
							<view class="flagWord" v-if="item.paySales != 0">回头客{{item.paySales}}</view>
						</view>
					</view>
				</template>
				
				<template v-slot:list2>
					<view>
						<view v-for="(item, index) in list2" :key="index" class="waterfall-item">
							<view @click="todetail(item.id)" class="waterfall-item__image">
								<image v-if="item.hasVideo" src="https://image.hzwltb69.com/app/imgs/chat/live.gif"
									class="lives" mode=""></image>
								<uv-image :src="item.img" mode="widthFix" width="350rpx">
									<template v-slot:loading>
										<image class="loadingLogo"
											src="https://image.hzwltb69.com/app/date/2023/lodingLogo.png"
											mode="widthFix"></image>
									</template>
								</uv-image>
							</view>
							<view class="p-title">
								{{item.name}}
							</view>
							<!-- <view class="p-pirce">
								<view class="">
									<text style="font-size: 22rpx;">￥</text>{{item.price}}
									<span
										style="font-size: 22rpx;color: #999999;margin-left: 20rpx;">{{item.paySales}}人付款</span>
								</view>
								<view class="cat">
									<img src="https://image.hzwltb69.com/app/date/2023/cat.png" alt="">
								</view>
							</view> -->
							<view class="p-pirce">
								<view class="">
									<text style="font-size: 22rpx;margin-right: 2rpx;">￥</text>{{item.price}}
								</view>
								<view class="cat">抢购</view>
							</view>
							<view class="line" v-if="item.paySales != 0"></view>
							<view class="flagWord" v-if="item.paySales != 0">回头客{{item.paySales}}</view>
						</view>
					</view>
				</template>
			</uv-waterfall>
			<view class="nomore" v-if="onEnd">没有更多了</view>
		</view>
	</view>
</template>

<script>
	export default {
		methods: {
			changeList(e) {
				this[e.name].push(e.value);
			},
			todetail(e) {
				this.$Router.push({
					path: '/pages/goods/detail',
					query: {
						id: e,
					}
				})
			},
			hasUserGet() {
				let that = this;
				that.$http('goods.getUniversalList', {
					current: that.page,
					pageSize: 10,
					themeFloorId: this.id,
				}).then(res => {
					if (res.data.list.length > 0) {
						if (that.goodsList.length == 0) {
							that.goodsList = res.data.list
							this.$emit('getImg', {
								backgroundImg: res.data.themeimg,
								name: res.data.title
							})
						} else {
							that.goodsList = that.goodsList.concat(res.data.list)
						}
					} else {
						this.onEnd = true
					}
				});
			},
		},
		data() {
			return {
				goodsList: [],
				list1: [], // 瀑布流第一列数据
				list2: [], // 瀑布流第二列数据
				rebate: 20, // 补贴
				id: null, // id
				onEnd: false
			}
		},
		created() {
			// this.hasUserGet()
		},
		props: {
			// 列表背景色
			backgroundColor: {
				type: String
			},
			// 分页
			page: {
				type: Number
			}
		}
	}
</script>

<style lang="scss" scoped>
	.nomore {
		text-align: center;
		padding: 20rpx;
		color: #999999;
		margin-top: 20rpx;
	}

	image {
		width: 350rpx !important;
	}

	.waterfall {
		background: #f6f6f6;
	}

	.waterfall-item {
		overflow: hidden;
		margin-top: 18rpx;
		border-radius: 15rpx;
	}

	.waterfall-item {
		background: #fff;

		.p-title {
			width: 350rpx;
			margin-top: 10rpx;
			padding: 0 10rpx;
			word-break: break-all;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
			
			font-size: 28rpx;
			font-weight: 600;
			color: #030303;
		}

		.p-pirce {
			padding: 16rpx 10rpx 10rpx;
			display: flex;
			justify-content: space-between;
			color: #000;
			font-weight: 600;
			font-size: 32rpx;
			align-items: center;
		
			.cat {
				width: 86rpx;
				height: 46rpx;
				color: rgba(255, 255, 255, 1);
				background-color: rgba(238, 38, 50, 1);
				border-radius: 32rpx;
				font-size: 22rpx;
				line-height: 46rpx;
				text-align: center;
			}
		}

		.butie-box {
			padding: 10rpx;

			.butie {
				// width: 100rpx;
				color: #db5235;
				height: 50rpx;
				line-height: 50rpx;
				font-size: 25rpx;
				display: inline-block;
				border: 1px solid #db5235;
				padding: 0 20rpx 0 20rpx;
				border-radius: 20rpx;
			}
		}
	}

	.waterfall-item__ft {
		padding: 20rpx;
		background: #fff;

		&__title {
			margin-bottom: 10rpx;
			line-height: 48rpx;
			font-weight: 700;

			.value {
				font-size: 32rpx;
				color: #303133;
			}
		}

		&__desc .value {
			font-size: 28rpx;
			color: #606266;
		}

		&__btn {
			padding: 10px 0;
		}
	}

	.lives {
		width: 40rpx !important;
		height: 40rpx !important;
		position: absolute;
		bottom: 20rpx;
		right: 20rpx;
		z-index: 10;
	}

	.waterfall-item__image {
		position: relative;
	}

	//::v-deep .loadingLogo div{
	//  background-size: 50% 50% !important;
	//  background-position: 50% !important;
	//}
	
	.line {
		width: 320rpx;
		height: 2rpx;
		color: rgba(80, 80, 80, 1);
		background-color: rgba(238, 237, 237, 1);
		margin: 10rpx auto;
	}
	
	.flagWord {
		color: rgba(188, 142, 93, 1);
		font-size: 24rpx;
		margin: 0 0 20rpx 16rpx;
	}
</style>